<template>
	<!-- 添加供应商 -->
	<view>
		<view class="boxtop">
			<text class="text">{{title}}</text>
		</view>
		<view class="item">
			<text class="text">供应商名称:</text>
			<input type="text" class="text1" placeholder="请输入供应商名称" v-model="name">
		</view>
		<view class="item">
			<text class="text">联系人名称:</text>
			<input type="text" class="text1" placeholder="请输入联系人名称" v-model="linl_name">
		</view>
		<view class="item">
			<text class="text">供应商电话:</text>
			<input type="text" class="text1" placeholder="请输入供应商电话" v-model="tel">
		</view>
		<view class="item">
			<text class="text">供应商所在:</text>
			<input type="text" class="text1" placeholder="请输入供应商所在" v-model="address">
		</view>
		<view class="item">
			<text class="text">供应商邮箱:</text>
			<input type="text" class="text1" placeholder="请输入供应商邮箱" v-model="email">
		</view>
		<view class="item">
			<text class="text">公司所在地:</text>
			<input type="text" class="text1" placeholder="请输入公司所在地" v-model="company_location">
		</view>
		<view class="item">
			<text class="text">开户银行名称:</text>
			<input type="text" class="text2" placeholder="请输入开户银行名称" v-model="bank_name">
		</view>
		<view class="item">
			<text class="text">开户银行账号:</text>
			<input type="text" class="text2" placeholder="请输入开户银行账号" v-model="bank_account">
		</view>
		<view class="btnbox">
			<button @click="instdata">保存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'添加供应商',
				name:'',linl_name:'',tel:'',address:'',email:'',company_location:'',bank_name:'',bank_account:''
			}
		},
		methods: {
			async instdata(){
				if(this.name.replace(/\s*/g,"").length == 0 ||
				   this.linl_name.replace(/\s*/g,"").length == 0 ||
				   this.tel.replace(/\s*/g,"").length == 0 ||
				   this.address.replace(/\s*/g,"").length == 0 ||
				   this.email.replace(/\s*/g,"").length == 0 ||
				   this.company_location.replace(/\s*/g,"").length == 0 ||
				   this.bank_name.replace(/\s*/g,"").length == 0 ||
				   this.bank_account.replace(/\s*/g,"").length == 0)
				   {
					uni.showToast({
						icon:"error",
						title:'内容不可为空'
					})
				} else {
					const res = await this.Request({
						url:'api/supplie/supadd',
						method:'POST',
						data:{name:this.name,linl_name:this.linl_name,tel:this.tel,
						address:this.address,email:this.email,bank_name:this.bank_name,
						bank_account:this.bank_account,company_location:this.company_location}
					})
					console.log(res.data.code)
					if(res.data.code=200){
						uni.showToast({
							title: '添加成功'
						})
						setTimeout(() => {
							uni.reLaunch({
								url:'/pages/public/supplie/supment'
							})
						},500)
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	.boxtop{
		width: 100%;
		background-color: #efefef;
		display: flex;
		border-bottom: 1px solid #ccc;
		.text{
			margin: 5px 0 5px 5px;
			font-size: 110%;
			font-weight: 700;
			color: #d3d3d3;
		}
	}
	.item{
		display: flex;
		height: 60px;
		margin: 5px;
		border-top: 1.5px solid #d3d3d3;
		border-bottom: 1.5px solid #d3d3d3;
		border-radius: 10px;
		.text{
			margin:auto 0;
			font-size: 16px;
			font-weight: 600;
		}
		.text1{
			margin:auto 0;
			margin-left: 46px;
		}
		.text2{
			margin:auto 0;
			margin-left: 30px;
		}
	}
	.btnbox{
		button{
			width: 60%;
			margin-left: 20%;
			margin-top: 10px;
			margin-bottom: 100px;
		}
	}
</style>
